#ifndef DW_GRAPHICS_PASS_H
# define DW_GRAPHICS_PASS_H

#	include "renderer.h" 

namespace dw
{
namespace graphics
{

using system::ISerializable;

class Pass : public ISerializable
{
// Constructors
public:

	Pass();

// Methods
public:

	const Renderer::State& getRenderState() const { return _renderState; }

	const Renderer::TextureUnit::State& getTextureUnitState(const unsigned i)	{ return _textureUnitStates[i]; }

	const std::string& getTextureName(const unsigned i)			{ return _textureNames[i]; }



	void setRenderState(const Renderer::State& state)	{ _renderState = state; }

		/** Set the state of a texture unit. */
	void setTextureUnitState(const unsigned i, const Renderer::TextureUnit::State& textureUnitState);

	/** Set the name of the texture to be bound at the given texture unit. */
	void setTextureName(const unsigned i, const std::string& textureName);



	/** Remove a texture unit/stage state given its index. */
	void removeTextureUnitState(const unsigned i);



	void begin();

	void end();



	std::string getSignature() const ;

	void serialize(ISerializer* serializer) const ;

	void deserialize(ISerializer* serializer);

// Typedefs
private:

	typedef std::map<unsigned, Renderer::TextureUnit::State>	TextureUnitStateMap;

	typedef std::map<unsigned, std::string>										TextureNameMap;

	typedef TextureUnitStateMap::iterator TextureUnitStateIterator;

	typedef TextureUnitStateMap::const_iterator TextureUnitStateConstIterator;

	typedef TextureNameMap::iterator TextureNameIterator;

	typedef TextureNameMap::const_iterator TextureNameConstIterator;

// Fields
private:

	Renderer::State _renderState;

	TextureUnitStateMap _textureUnitStates;

	TextureNameMap _textureNames;

// Friends
private:

	friend 
	std::ostream& operator<<(std::ostream&, const Pass&);
	
	friend 
	std::istream& operator>>(std::istream&, Pass&);

};

} // namespace graphics
} // namespace dw

#endif // !DW_GRAPHICS_PASS_H